<?php

$m = new Mongo();

$db = $m->EMU;

$collection = $db->equipment;

$userQuery = array('barcode' =>  $_POST['barcode']);

$cursor = $collection->findOne($userQuery);


if($cursor != NULL)
{
	$collection->remove(array('barcode' => $_POST['barcode']), array("justOne" => true));
	Header("Location: ../equipment.php");
}
else {
	Header("Location: ../equipment.php?error=deleteErrorEquipment");
}
?>